//
//  HomeDataTool.m
//  laowu
//
//  Created by Northwan on 15/4/30.
//  Copyright (c) 2015年 长沙市岳麓区立早网络科技有限公司. All rights reserved.
//

#import "HomeDataTool.h"

@implementation HomeDataTool
+(void)getTrainInfoData:(NSInteger)maxId keywords:(NSString*)keywords success:(void (^)(TrainInfoRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *param =[NSMutableDictionary dictionary];
    [param setObject:APP_KEY_VALUE forKey:APP_KEY_KEY];
    [param setObject:[NSNumber numberWithInteger:maxId] forKey:@"max_id"];
    if(!ISBLANK(keywords)){
        [param setObject:keywords forKey:@"search_name"];
    }
    [self getWithUrl:[NSString stringWithFormat:@"%@api/train_list.json",BASE_URL] param:param resultClass:[TrainInfoRes class] success:success failure:failure];
}

+(void)applyTrainInfo:(NSInteger)contentId success:(void (^)(BaseResponse *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *param =[NSMutableDictionary dictionary];
    [param setObject:APP_KEY_VALUE forKey:APP_KEY_KEY];
     NSInteger userId = [UserDefaultsHelper integerForKey:KEY_USER_ID];
    [param setObject:[NSNumber numberWithInteger:userId] forKey:@"user_id"];	
    [param setObject:[NSNumber numberWithInteger:contentId] forKey:@"content_id"];
    [self getWithUrl:[NSString stringWithFormat:@"%@api/trainapply.json",BASE_URL] param:param resultClass:[BaseResponse class] success:success failure:failure];
}

+(void)getResumeInfo:(void (^)(ResumeRes *))success failure:(void (^)(NSError *))failure{
    NSMutableDictionary *param =[NSMutableDictionary dictionary];
    [param setObject:APP_KEY_VALUE forKey:APP_KEY_KEY];
    NSString *userId = [UserDefaultsHelper stringForKey:KEY_USER_ID];
    [param setObject:userId forKey:@"user_id"];
    [self getWithUrl:[NSString stringWithFormat:@"%@api/resume_info.json",BASE_URL] param:param resultClass:[ResumeRes class] success:success failure:failure];
}
+(void)setResumeInfo:(NSString *)workType techLevel:(NSString *)techLevel salary:(NSString *)salary province:(NSString *)province city:(NSString *)city success:(void (^)(BaseResponse *))success failure:(void (^)(NSError *))failure      {
    NSMutableDictionary *param =[NSMutableDictionary dictionary];
    [param setObject:APP_KEY_VALUE forKey:APP_KEY_KEY];
    NSString *userId = [UserDefaultsHelper stringForKey:KEY_USER_ID];
    [param setObject:userId forKey:@"user_id"];
    [param setObject:workType forKey:@"work_type"];
    [param setObject:techLevel forKey:@"work_skil_level"];
    [param setObject:salary forKey:@"salary"];
    [param setObject:province forKey:@"province"];
    [param setObject:city forKey:@"city"];
    [self postWithUrl:[NSString stringWithFormat:@"%@api/resume_save.json",BASE_URL] param:param resultClass:[BaseResponse class] success:success failure:failure];
}

+(void)uploadProjectWithParam:(NSDictionary *)params success:(void (^)(BaseResponse *result))success failure:(void (^)(NSError *error))failure{
    NSMutableDictionary *param =[NSMutableDictionary dictionaryWithDictionary:params];
    [param setObject:APP_KEY_VALUE forKey:APP_KEY_KEY];
    NSString *userId = [UserDefaultsHelper stringForKey:KEY_USER_ID];
    [param setObject:userId forKey:@"user_id"];
    [self postWithUrl:[NSString stringWithFormat:@"%@api/project/upload.json",BASE_URL] param:param resultClass:[BaseResponse class] success:success failure:failure];
    //api/project/upload.json
}

+(void)pushBindWithChannelId:(NSString *)channelId bUserId:(NSString *)bUserId success:(void (^)(BaseResponse *result))success failure:(void (^)(NSError *error))failure{
    NSMutableDictionary *param =[NSMutableDictionary dictionary];
    [param setObject:APP_KEY_VALUE forKey:APP_KEY_KEY];
    NSString *userId = [UserDefaultsHelper stringForKey:KEY_USER_ID];
    [param setObject:userId forKey:@"user_id"];
    
    [param setObject:channelId forKey:@"p_channel_id"];
    [param setObject:bUserId forKey:@"p_user_id"];
    [param setObject:@(1) forKey:@"drive"];
    [self postWithUrl:[NSString stringWithFormat:@"%@api/push/bind.json",BASE_URL] param:param resultClass:[BaseResponse class] success:success failure:failure];
}

+(void)getResumeListWithKeyword:(NSString*)key_word area:(NSString*)area job:(NSString*)job start:(NSString*)start end:(NSString*)end maxId:(NSInteger)maxId success:(void (^)(ResumeListRes *result))success failure:(void (^)(NSError *error))failure{
    NSMutableDictionary *param =[NSMutableDictionary dictionary];
    [param setObject:APP_KEY_VALUE forKey:APP_KEY_KEY];
    [param setObject:@(maxId) forKey:@"max_id"];
    [param setObject:key_word forKey:@"key_word"];
    [param setObject:area forKey:@"area"];
    [param setObject:job forKey:@"job"];
    [param setObject:start forKey:@"start"];
    [param setObject:end forKey:@"end"];
    [self postWithUrl:[NSString stringWithFormat:@"%@api/resume_list.json",BASE_URL] param:param resultClass:[ResumeListRes class] success:success failure:failure];
}

@end
